package com.ky.server.service;

import com.ky.common.dto.Dto;
import com.ky.server.dao.FileDao;

public class DownloadService implements Service<Long>{

	@Override
	public Dto service(Long id) {
		
		Dto<byte[]> responseDto = new Dto<>();
		//通过文件id查找文件，转换为字节数组
		byte[] bs = FileDao.getFileBsById(id);
		//判断问价字节数组是否存在
		if(bs!=null) {
			responseDto.setCode(200);
			responseDto.setData(bs);
			
		}else {
			responseDto.setCode(10001);
			responseDto.setErrorMsg("文件不存在，下载失败！");
		}
		
		
		return responseDto;
	}

}
